import { useLayoutEffect, useState } from "react";
import { useLocation } from "react-router-dom";
import { comDataSource } from "./comDataSource";
import "./index.less";
const ProdectDetail = () => {
  const location = useLocation();
  const [currentPage, setCurrentPage] = useState<any>();
  useLayoutEffect(() => {
    setCurrentPage(location.pathname.split("/")?.[1]);
  }, []);
  return (
    <div className="com-banner-wrap">
      <div className="com-banner-detail">
        <div className="title">配件详情</div>
        <div className="detail-item">
          {comDataSource.map((item) => {
            if (currentPage === item.name) {
              return item.children.map((key) => {
                return (
                  <img src={key.children} key={item.name} alt="详情图片" />
                );
              });
            }
          })}
        </div>
      </div>
    </div>
  );
};
export default ProdectDetail;
